<template>
	<view>
		<indexCommonList :item="detailData"></indexCommonList>
		<view class="commentBox">
			<view class="comment-title">最新评论   1</view>
			<block v-for="(lib,index) in commentList" :key="index">
				<commentList :lib="lib"></commentList>
			</block>
		</view>
		<view class="searchNone"></view>
		<!-- 输入框 -->
		<chatSearch  @submit="submit"></chatSearch>
		<!-- 分享 -->
		<share @shareMsk="shareMsk" :shareShow="shareShow" :share="share"></share>
	</view>
</template>

<script>
	import chatSearch from '../../components/chat-list/chat-search.vue'
	import share from '../../components/index/share/share.vue'
	import time from '../../common/time.js'
	import indexCommonList from '../../components/index/index-common-list/index-common-list.vue';
	import commentList from '../../components/index/comment-list/comment-list.vue';
	export default {
		data() {
			return {
				detailData:{},
				commentList:[],
				shareShow:false,
				share:{
					providerList:[],
					href:"https://uniapp.dcloud.io",
					image: '',
					shareType:1,//1文字2图片0图文5小程序
				}
			}
		},
		components: {
			indexCommonList,
			commentList,
			chatSearch,
			share
		},
		onLoad(e) {
			console.log(e)
			this.initData(JSON.parse(e.data))
			this.getComment();
			this.getShare()
		},
		onNavigationBarButtonTap(e){
			if(e.index ==0){
				this.shareShow=true;
			}
		},
		methods: {
			initData(obj){
				this.detailData={
							userheadpic: '../../static/img/userpic/13.jpg',
							userhead: '小甜甜',
							sex: 1,
							userage: '15',
							isfollow: false,
							usertext: '花想一双月相容onLaunch	当uni-app 初始化完成时触发（全局只触发一次）',
							userType: '1', //0img 1 video2发布，
							userPic: '../../static/img/datapic/15.jpg',
							userPlayNum: '20w',
							userplayLong: '2:45',
							useraddress: '北京 门头沟',
							userinfo: {
								forward: 20,
								news: 35,
								fabulous: 2222
							}
						};
				uni.setNavigationBarTitle({
				    title: obj.title
				});
			},
			getComment(){
				let arr=[
					{
						headpic: '../../static/img/userpic/5.jpg',
						head: '小甜甜',
						data: '花想一双月相容onLaunc',
						days:'1588230672',
						id:0,
						pid:0
					},
					{
						headpic: '../../static/img/userpic/6.jpg',
						head: '小甜甜',
						data: '花想一双月相容onLaunc',
						days:'1588230672',
						id:1,
						pid:1
					},
					{
						headpic: '../../static/img/userpic/13.jpg',
						head: '小甜甜',
						data: '花想一双月相容onLaunc',
						days:'1588230672',
						id:2,
						pid:1
					}
				]
				arr.forEach((item)=>{
					item.days=time.gettime.gettime(item.days)
				})
				this.commentList=arr;
			},
			submit(text){
				let now=new Date().getTime()
				var obj={
						headpic: '../../static/img/userpic/5.jpg',
						head: '小甜甜',
						data: text,
						days:now,
						id:4,
						pid:1
					}
					this.commentList.push(obj)
					
			},
			shareMsk(e){
				this.shareShow=!this.shareShow;
			},
			//获取分享数据
			getShare(){
				console.log(222)
				let data = [
					{
						name: '微信好友',
						id: 'weixin',
						sort:0,
						icon:'icon-weixin',
						zclass:'share-wx'
					},
					{
						name: '朋友圈',
						id: 'weixin',
						type:'WXSenceTimeline',
						sort:1,
						icon:'icon-faxian',
						zclass:'share-py'
					},
					{
						name: '新浪微博',
						id: 'sinaweibo',
						sort:2,
						icon:'icon-xinlangweibo',
						zclass:'share-wb'
					},
					{
						name: 'QQ',
						id: 'qq',
						sort:3,
						icon:'icon-QQ',
						zclass:'share-qq'
					}
				];
				this.share.providerList = data.sort((x,y) => {
					return x.sort - y.sort
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
.commentBox{
	padding: 20upx;
	.comment-title{
		font-weight: bold;
	}
	
}
.searchNone{
		height: 100upx;
	}
	
</style>
